/**
 * 
 */
package servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import metier.Article;
import metier.Bean;
import metier.CategorieSport;

import org.apache.log4j.Logger;

import persistence.Strategie;
import persistence.DAO.DAO;
import persistence.Factories.DAOFactory;

/**
 * @author hozakan
 *
 */
public class GoToFebruary extends BaseServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -222208639614442818L;
	private static final Logger LOGGER = Logger.getLogger(GoToFebruary.class);

	/* (non-Javadoc)
	 * @see servlets.BaseServlet#specificDoGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void specificDoGet(HttpServletRequest request,
			HttpServletResponse response) {Strategie strat = Strategie.getInstance();
		DAOFactory factory = strat.getDAOFactory();
		DAO dao = factory.getDAO(new Article());
		List<Bean> beans = dao.getBeans();
		List<Article> list = new ArrayList<Article>();
		for (int i  =0 ;i<beans.size();i++)
			if (beans != null &&  ((Article)beans.get(i)).getDateCreation().getMonth()==1) {
				list.add((Article) beans.get(i));
			}
		request.getSession(false).setAttribute("artFeb", list);
		try {
			System.out.println("mapping débuté");
			request.getRequestDispatcher("pages/newsFeb.jsp").forward(request, response);
		} catch (ServletException e) {
			LOGGER.error("Impossible de rediriger vers la page d'administration");
		} catch (IOException e) {
			LOGGER.error("La page d'administration n'a pas été trouvée à l'endroit indiqué");
		}
	}

	/*__________________________________________________________*/
	/**
	 * @param request
	 * @param response
	 * @see servlets.BaseServlet#specificDoPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void specificDoPost(HttpServletRequest request,
			HttpServletResponse response)
	{
		// A compéter Auto-generated method stub
		
	}

}
